package _04文件上传案例;

import java.io.*;
import java.net.Socket;

public class TCPClient {
    public static void main(String[] args) throws IOException {
        System.out.println("客户端启动");
        Socket socket = new Socket("192.168.88.57",10086);
        OutputStream socketOutputStream = socket.getOutputStream();
        InputStream socketInputStream = socket.getInputStream();


        FileInputStream fis = new FileInputStream("day12\\客户端文件夹\\jz.jpg");

        byte[] bytes = new byte[1024];
        int read;
        while ((read=fis.read(bytes))!=-1){
            socketOutputStream.write(bytes,0,read);
        }
        socket.shutdownOutput();//中断socket输出流

        System.out.println("客户端传输完毕");


        while ((read=socketInputStream.read(bytes))!=-1) {
            System.out.println(new String(bytes,0,read));
        }

        socketInputStream.close();
        socketOutputStream.close();
        fis.close();
        socket.close();
    }
}
